//
//  main.m
//  OC6_作业练习
//
//  Created by dllo on 15/11/1.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Contact.h"
#import "ContactManager.h"


int main(int argc, const char * argv[]) {

    ContactManager *contactList = [[ContactManager alloc] init];
    
    Contact *c1 = [[Contact alloc] initWithName:@"Djjj" sex:@"male" phone:@"1333333" address:@"西山" group:@"同学" age:22];
    Contact *c2 = [[Contact alloc] initWithName:@"Cjjj" sex:@"female" phone:@"1444444" address:@"马兰" group:@"朋友" age:88];
    Contact *c3 = [[Contact alloc] initWithName:@"Phhh" sex:@"male" phone:@"1444444" address:@"春柳" group:@"家人" age:77];
    Contact *c4 = [[Contact alloc] initWithName:@"Caaa" sex:@"female" phone:@"1555555" address:@"南沙" group:@"同学" age:66];
    
    
    // 3, 添加
    [contactList addPerson:c1];
    [contactList addPerson:c2];
    [contactList addPerson:c3];
    [contactList addPerson:c4];
    
    
    // 4,获取某个分组名称下所有联系人，并且按照姓名升序排列。
    
//    NSMutableArray *arr = [contactList sortByName:@"C"];
//    for (Contact *contact in arr) {
//        NSLog(@"%@ %@ %@ %@ %@ %ld", [contact name], [contact sex], [contact phone], [contact address], [contact group], [contact age]);
//    }

    // 5, 电话号找人
    
//    NSMutableArray *arr = [contactList searchByPhone:@"1555555"];
//    for (Contact *contact in arr) {
//        NSLog(@"%@ %@ %@ %@ %@ %ld", [contact name], [contact sex], [contact phone], [contact address], [contact group], [contact age]);
//    }
    
    // 6,获取所有女性的联系人，并且按照年龄的降序排列。
//    NSMutableArray *arr = [contactList sortByAge];
//        for (Contact *contact in arr) {
//            NSLog(@"%@ %@ %@ %@ %@ %ld", [contact name], [contact sex], [contact phone], [contact address], [contact group], [contact age]);
//        }
    
    // 7, 根据名字删除
    
//    [contactList deleteByName:@"Cjjj"];
    
    // 8, 删除某个分组
    [contactList deleteByKey:@"C"];
    
    
    
    
    
    // 1,显示联系人
    [contactList infoAllContact];
    
    
    
    return 0;
}
